package com.dianhun.cn.send;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author cyt
 * @create 2020-08-24 13:55
 */
@Component
public class Sender {

    @Autowired
    private AmqpTemplate rabbitTemplate;

    public void send() {
        String context = "hello - > " + new Date();
        System.out.println("Sender :" + context);
        //hello为创建的队列名,context为发送的消息
        this.rabbitTemplate.convertAndSend("hello", context);
    }
}
